help.bash

#!/usr/bin/env bash

##
#
# @tip View all functions and extended help
function help(){
    helpFor="${1}"
    if [[ -z "$help_mode" ]];then
        # help_mode="run"
        help_mode="help"
    fi

    if [[ -z "$helpFor" ]];then
        _help_bash_cli_root
        . "${codeDir}/help/help_groups.bash"
        return;
    fi


    helpFile="${codeDir}/help/${helpFor}.bash"

    if [[ -f "$helpFile" ]];then
        command_group="${helpFor}"
        _help_bash_cli_sub
        help_mode="run"
        . $helpFile
        return
    fi


    msg_notice "No help menu for '${helpFor}'"
}

function _help_bash_cli_root(){
    msg_header "How to use"
    msg_instruct "  ${bash_cli_script_name} [command_group] [command]"
    msg
    msg "  Choose a ${cMark}[command_group]${cOff} for more help."
    # msg "Choose one to view its ${cMark}[commands]${cOff}"
}


function _help_bash_cli_sub(){
    msg_header "How to use"
    if [[ "$command_group" == "core" ]];then
        msg_instruct "  ${bash_cli_script_name} [command]"
        msg "    - default ${cMark}[command_group]${cOff} is ${cInstruct}core${cOff} so it can be ommitted"
    else
        msg_instruct "  ${bash_cli_script_name} ${command_group} [command]"
    fi
    msg
    msg "  Choose a ${cMark}[command]${cOff}"
}